<%@tag pageEncoding="UTF-8" language="java"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ attribute name="url" required="true" description=" a link" type="java.lang.String"%>
<%@ attribute name="pageSize" description="the page show number size, default 8" type="java.lang.Integer"%>
<%@ attribute name="pageNo" required="true" description="current page" type="java.lang.Integer"%>
<%@ attribute name="totalPage" required="true" description="max page" type="java.lang.Long"%>
<%
    boolean bl = url.indexOf('?') != -1;
%>
<ul>
	<li <%=pageNo <= 1 ? "class='disabled'" : ""%>><a
		href="<%=pageNo > 1 ? (url + (bl ? "&" : "?") + "p=" + (pageNo - 1)) : "#"%>">前一页</a></li>
	<%
	    if (pageSize == null) {
			pageSize = 8;
	    }
	    long start = 0, end = 0;
	    if (pageNo - pageSize < 0) {
			start = 1L;
			end = pageSize;
	    } else {
			start = pageNo - (pageSize / 2);
			end = start + pageSize - 1;
	    }
	    if (end > totalPage) {
			end = totalPage;
	    }

	    for (long i = start; i <= end; i++) {
	%>
	<li <%=pageNo == i ? "class='active'" : ""%>><a href="<%=url + (bl ? "&" : "?") + "p=" + i%>"><%=i%></a></li>
	<%
	    }
	%>
	<li <%=pageNo >= totalPage ? "class='disabled'" : ""%>><a
		href="<%=pageNo < totalPage ? (url + (bl ? "&" : "?") + "p=" + (pageNo + 1)) : "#"%>">后一页</a></li>
</ul>


